package view

var online = `{{define "online"}}
{{template "header" .}}
 <div id="onlineContent">
 {{template "onlineContent" .}}  
 </div>     
<SCRIPT LANGUAGE="JavaScript">
var refreshTimeOut = 20000; 
function show_ktv_online_list(){		
	$('#onlineContent').load('/ktv/onlinedata/{{.cur_offset}}');	
	setTimeout("show_ktv_online_list()",refreshTimeOut);
} 

$(document).ready(function(){
	setTimeout("show_ktv_online_list()",refreshTimeOut);
});
</SCRIPT>
{{template "footer" .}}
{{end}}`

var onlineContent = `{{define "onlineContent"}}
<div class="col-md-12" role="main"><h3>在线用户</h3>
        <div class="pull-right">&nbsp;&nbsp;&nbsp;&nbsp;用户总数: {{.total}} &nbsp;&nbsp;&nbsp;&nbsp;</div> <hr>
        	<div class="table-responsive"><table class="table table-bordered table-striped">
	            <thead>
					<tr>	
					<th>序号</th>												
					<th>IP地址</th>
					<th class="location">地区</th>
					<th>注册码</th>	
					<th>有效期</th>
					<th>限速</th>					
					<th>最后更新</th>						
					<th>已接收</th>
					<th>已发送</th>
					<th>下载</th>					
					<th>当前速率</th>			
					<th>操作</th>
					</tr>
				</thead>

				<tbody>

				{{range $index, $sess := .sessions}}
				<tr>			
				<td>{{$sess.Number}}</td>			
				<td>{{$sess.GetIPAddress}}</td>		
				<td class="location">{{$sess.GetLocation}}</td>	
				<td>{{$sess.GetShortUserCode}}</td>
				<td>{{$sess.ExpirationDateString}}</td>
				<td>{{$sess.GetSpeed}} KB/S</td>			
				<td title="{{$sess.LoginDateString}} 登录">{{$sess.ActiveDateString}}</td>				
				<td>{{transfer $sess.GetTotalRecvBytes}}</td>
				<td>{{transfer $sess.GetTotalSentBytes}}</td>
				<td>{{$sess.GetDownloadCount}}</td>				
				<td>{{transfer $sess.GetLastSpeed}}/S</td>
				<td style="width: auto"><a href="/ktv/detail/{{$sess.GetTokenHex}}">查看</a></td>
				</tr>
				{{end}}

				{{ if .noonlineuser }}
				<tr>				
				<td colspan="12">没有记录</td>		
				</tr>
				{{end}}

				</tbody>
			</table></div>
			<p>		
			<a href="/ktv/online/{{.pre_offset}}" class="btn btn-default" role="button">上一页</a>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="/ktv/online/{{.next_offset}}" class="btn btn-default" role="button">下一页</a>				
			<a href="/ktv/online/{{.cur_offset}}" class="btn btn-default pull-right" role="button">刷 新</a>
			</p>
		</div>
{{end}}`
